
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - FooTable</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/footable/footable.core.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">

            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>病人列表</h5>                       
                        </div>
                        <div class="ibox-content">

                            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="8">
                                <thead>
                                <tr>

                                    <th data-toggle="true">ID</th>
                                    <th>姓名</th>
                                    <!--<th>提交时间</th>-->
                                    <th data-hide="all">性别</th>
                                    
                                    <th data-hide="all">年龄</th>
                                    <th data-hide="all">身份证号</th>
                                    <th data-hide="all">手机号</th>
                                    <th data-hide="all">密码</th>
                                    <th>操&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;作</th>
                                </tr>
                                </thead>
                                <tbody id="tbody">
                                	
                                <tr>
                                	<td>1</td>
                                    <td>张飞</td>
                                    <td>女</td>
                                    <td>28</td>
                                    <td>371522199999994545</td>
                                    <td>12345678901</td>
                                    <td>s8sd4sa6</td>
                                    <td>
                                    	<a data-toggle="modal" href="form_basic.html#repdoc">修改</a>&nbsp;
                                    	<a href="">删除</a>
                                    </td>
                                </tr>                             
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="5">
                                        <ul class="pagination pull-right"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                                
                            </table>
<!--                            <a data-toggle="modal" class="btn btn-primary" href="form_basic.html#adddoc">注册账户</a>-->
                        </div>
                    </div>
                </div>
            </div>
            
        </div>
        
        

    <div id="adddoc" class="modal fade" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-6 b-r">
                            <h3 class="m-t-none m-b">注册一个用户账户</h3>
                            <form role="form">
                                <div class="form-group">
                                    <label>姓名：</label>
                                    <input id="name" type="text" placeholder="请输入用户名" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>身份证号：</label>
                                    <input id="card" type="text" placeholder="请输入身份证号" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>年龄：</label>
                                    <input id="age" type="number" placeholder="请输入年龄" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>性别：</label>
                                    <select class="form-control" id="sex">
                                    	<option value="0">男</option>
                                    	<option value="1">女</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>电话：</label>
                                    <input id="phone" type="text" placeholder="请输入手机号" class="form-control">
                                </div>
                                <div class="form-group">
                                    <label>密码：</label>
                                    <input id="password" type="password" placeholder="请输入密码" class="form-control" value="123456">
                                    <a style="color: red; font-size: 12px;"> *默认密码为123456</a>
                                </div>
                                <br>
                                <div>
                                    <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>注册</strong>
                                    </button>
                                    
                                </div>
                            </form>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
<!--    <div id="repdoc" class="modal fade" aria-hidden="true">-->
<!--        <div class="modal-dialog">-->
<!--            <div class="modal-content">-->
<!--                <div class="modal-body">-->
<!--                    <div class="row">-->
<!--                        <div class="col-sm-6 b-r">-->
<!--                            <h3 class="m-t-none m-b">修改病人信息</h3>-->
<!--                            <form role="form">-->
<!--                                <div class="form-group">-->
<!--                                    <label>姓名：</label>-->
<!--                                    <input id="name" type="text" placeholder="请输入用户名" class="form-control">-->
<!--                                </div>-->
<!--                                <div class="form-group">-->
<!--                                    <label>身份证号：</label>-->
<!--                                    <input id="card" type="text" placeholder="请输入身份证号" class="form-control">-->
<!--                                </div>-->
<!--                                <div class="form-group">-->
<!--                                    <label>年龄：</label>-->
<!--                                    <input id="age" type="number" placeholder="请输入年龄" class="form-control">-->
<!--                                </div>-->
<!--                                <div class="form-group">-->
<!--                                    <label>性别：</label>-->
<!--                                    <select class="form-control" id="sex">-->
<!--                                    	<option value="0">男</option>-->
<!--                                    	<option value="1">女</option>-->
<!--                                    </select>-->
<!--                                </div>-->
<!--                                <div class="form-group">-->
<!--                                    <label>电话：</label>-->
<!--                                    <input id="phone" type="text" placeholder="请输入手机号" class="form-control">-->
<!--                                </div>-->
<!--                                <div class="form-group">-->
<!--                                    <label>密码：</label>-->
<!--                                    <input id="password" type="password" placeholder="请输入密码" class="form-control">-->
<!--                                    -->
<!--                                </div>-->
<!--                                <br>-->
<!--                                <div>-->
<!--                                    <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>确认修改</strong>-->
<!--                                    </button>-->
<!--                                    -->
<!--                                </div>-->
<!--                            </form>-->
<!--                        </div>-->
<!--                        -->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <script src="js/plugins/footable/footable.all.min.js"></script>

    <!-- 自定义js -->
    <script>
        $(document).ready(function() {
            selectUsers();
            $('.footable').footable();
            $('.footable2').footable();

        });
        // selectUsers

        function selectUsers() {
            $.ajax({
                async: false,
                type: "post",
                url: "/selectUsers",
                contentType: 'application/json',
                dataType: "text",
                success: function (data) {
                    var result = JSON.parse(data);
                    console.log(result);
                    if (result.SUCCESS) {
                        list = result.RESULT;
                        console.log(list);
                        makeList(list)
                    } else {
                        console.log(result.RESULT);
                    }
                },
                error: function (data) {
                    alert("请求失败");
                }
            });
        }


        function makeList(list) {

            var html = "";
            for (var i = 0; i < list.length; i++) {
                /**
                 <th data-toggle="true">ID</th>
                 <th>姓名</th>
                 <!--<th>提交时间</th>-->
                 <th data-hide="all">性别</th>

                 <th data-hide="all">年龄</th>
                 <th data-hide="all">身份证号</th>
                 <th data-hide="all">手机号</th>
                 <th data-hide="all">密码</th>
                 <th>操&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;作</th>
                 </tr>
                 */
                var k = i+ 1;
                html += " <tr><td>" + k + "</td>    ";
                html += " <td>" + list[i].name + "</td>    ";
                if (list.sex == 1) {
                    html += " <td>" + "女" + "</td>";
                } else {
                    html += " <td>" + "男" + "</td>";
                }
                html += " <td>" + list[i].age + "</td>";
                html += " <td>" + list[i].card + "</td>";
                html += " <td>" + list[i].phone + "</td>";
                html += " <td>" + list[i].password + "</td>";
                html += " <td><a href='' onclick='delUser(" + list[i].id + ")'>删除</a></td></tr>";
            }
            $('#tbody').html(html);
            console.log(html);
        }

        function delUser(id) {
            $.ajax({
                async: true,
                type: "post",
                url: "/delUser",
                data: JSON.stringify({id: id}),
                contentType: 'application/json',
                dataType: "text",
                success: function (data) {
                    var result = JSON.parse(data);
                    console.log(result);
                    if (result.SUCCESS) {
                        alert(result.RESULT);
                        window.location.href = "/admin-user.html";
                    } else {
                        alert(result.RESULT);
                    }
                },
                error: function (data) {
                    alert("请求失败");
                }
            });

        }


    </script>

</body>

</html>
